package com.dream.myqiyi.ui;

import com.dream.myqiyi.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class AccountActivity extends Activity {
	private ImageButton mRetIB;
	private ImageButton mLogoutIB;
	private SharedPreferences sp = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.user_view);
		sp = this.getSharedPreferences("userinfo", Context.MODE_PRIVATE);

		prepareView();
		//mTitleView.setText(R.string.category_account);
	}

	private void prepareView() {
		//mTitleView = (TextView) findViewById(R.id.title_text);
		mRetIB = (ImageButton) findViewById(R.id.return_btn);
		mRetIB.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent intent = new Intent(AccountActivity.this, MainActivity.class);
				startActivity(intent);
			}

		});
		mLogoutIB = (ImageButton) findViewById(R.id.logout_btn);
		mLogoutIB.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Editor editor = sp.edit();
				editor.putString("username", "");
		    	editor.putString("password", "");
		    	editor.putBoolean("autologin", false);


				Intent intent = new Intent(AccountActivity.this, Login.class);
				startActivity(intent);
			}

		});
	}
}
